package com.concurrent.main;

import com.concurrent.entity.User;
import com.concurrent.entity.Zoo;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;

/**
 * @program: concurrent_project
 * @description: 测试类
 * @author: Wednesday
 * @create: 2020-06-10 11:11
 **/
public class CountDawnLatchTester {
    public static void main(String[] args) throws InterruptedException {
        //初始化CountDownLatch并设置
        CountDownLatch latch = new CountDownLatch(3);

        List<Thread> threads = new ArrayList<>(3);
        threads.add(new Thread(new User(latch, "张三")));
        threads.add(new Thread(new User(latch, "李四")));
        threads.add(new Thread(new User(latch, "王五")));

        for (Thread thread :
                threads) {
            thread.start();
        }

//        Thread.sleep(100);
        new Thread(new Zoo(latch,"动物园")).start();
    }
}
